import React from 'react';
import { Spin as AntdSpin } from 'antd';
import type { SpinProps as AntdSpinProps } from 'antd';
import { createStyles } from 'antd-style';

export interface SpinProps extends AntdSpinProps {
  /**
   * @description 自定义样式类名
   */
  customClassName?: string;
}

const useStyles = createStyles(({ token, css }) => ({
  spin: css`
    .ant-spin-dot-item {
      background-color: ${token.colorPrimary};
    }
  `,
}));

const Spin: React.FC<SpinProps> = ({ customClassName, className, ...restProps }) => {
  const { styles, cx } = useStyles();
  
  const spinClassName = cx(
    className,
    customClassName,
    styles.spin
  );

  return <AntdSpin className={spinClassName} {...restProps} />;
};

export { Spin };
export default Spin;

